use serde::Deserialize;
use lazy_static::lazy_static;
use toml;
#[derive(Debug, Deserialize)]
pub struct Config {
    pub server: ServerConfig,
    // sync: SyncConfig,
    // auth: AuthConfig,
}

#[derive(Debug, Deserialize)]
pub struct ServerConfig {
    pub address: String,
    // ssl: bool,
}

lazy_static! {
    static ref CONFIG: Option<Config> = load_config();
}
pub fn load_config() -> Option<Config> {
    let contents = std::fs::read_to_string("/src/config/config.toml").ok()?;
    println!("contents: {}", contents);
    let config: Config = toml::from_str(&contents).ok()?;
    Some(config)
}

pub fn get_config() -> Option<Config> {
    // CONFIG.as_ref()
    load_config()
}
